package com.yanqu.road.server.cmd.tradewar;

import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.cross.tradewar.CrossTradeWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_TRADE_WAR_QUERY_ENEMY_PATRONS, desc = "跨服查询商战对手门客")
public class CrossTradeWarCrossQueryEnemyPatronsCmd extends CrossUnionCommand {
    private int activityId;
    private long enemyUserId;
    private long enemyServerId;
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarQueryEnemyPatronsReqMsg reqMsg = CrossTradeWarProto.CrossTradeWarQueryEnemyPatronsReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        enemyUserId = reqMsg.getEnemyUserId();
        enemyServerId = reqMsg.getEnemyServerId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarCrossQueryEnemyPatronsReqMsg.Builder queryMsg = CrossTradeWarProto.CrossTradeWarCrossQueryEnemyPatronsReqMsg.newBuilder();
        queryMsg.setMyUserId(userId);
        queryMsg.setMyServerId(serverId);
        queryMsg.setActivityId(activityId);
        queryMsg.setEnemyUserId(enemyUserId);
        queryMsg.setEnemyServerId(enemyServerId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_TRADE_WAR_CROSS_QUERY_ENEMY_PATRONS, queryMsg);
        MessageHelper.sendPacket(enemyServerId, enemyUserId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
